package com.cooksys.film_rental.model.forms;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;

import com.cooksys.film_rental.validation.constraints.PasswordsMatch;
import com.cooksys.film_rental.validation.constraints.UniqueUsername;

/**
 * Backing object for the registration form
 * 
 * @author Peter Zastoupil
 * 
 */
@PasswordsMatch
public class RegistrationForm {

	@NotEmpty
	@Size(max = 45)
	@UniqueUsername
	String userId;

	@NotEmpty
	@Size(max = 15)
	String password;

	String confirmPassword;

	@NotEmpty
	@Pattern(regexp = "[.[^(NONE)]]+")
	String storeId;

	@NotEmpty
	@Size(max = 45)
	String firstName;

	@NotEmpty
	@Size(max = 45)
	String lastName;

	@Size(max = 50)
	@Email
	String email;

	@NotEmpty
	@Size(max = 50)
	String addressLine1;

	@Size(max = 50)
	String addressLine2;

	@NotEmpty
	@Size(max = 20)
	String district;

	@NotEmpty
	@Size(max = 50)
	String cityName;

	@NotEmpty
	@Pattern(regexp = "[.[^(NONE)]]+")
	String countryId;

	@Size(max = 10)
	String postalCode;

	@NotEmpty
	@Size(max = 20)
	String phoneNumber;

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public String getStoreId() {
		return storeId;
	}

	public void setStoreId(String storeId) {
		this.storeId = storeId;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddressLine1() {
		return addressLine1;
	}

	public void setAddressLine1(String addressLine1) {
		this.addressLine1 = addressLine1;
	}

	public String getAddressLine2() {
		return addressLine2;
	}

	public void setAddressLine2(String addressLine2) {
		this.addressLine2 = addressLine2;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getCountryId() {
		return countryId;
	}

	public void setCountryId(String countryId) {
		this.countryId = countryId;
	}

	public String getPostalCode() {
		return postalCode;
	}

	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	@AssertTrue
	public boolean passwordsMatch() {
		return (this.password != null && this.confirmPassword != null && this.password
				.equals(confirmPassword));
	}

}
